//
//  CosmeticViewController.m
//  DA_V
//
//  Created by 中亿世联前台 on 15/4/21.
//  Copyright (c) 2015年 zhouhai. All rights reserved.
//

#import "CosmeticViewController.h"
#import "CommodityListViewController.h"
#import "CosmeticTableViewCell.h"
#import "CosMeticList_TableViewCell.h"
#import "InformationButton.h"
#import "InterFace.h"

@interface CosmeticViewController ()

@end

@implementation CosmeticViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.navigationItem setHidesBackButton:YES];
    [self createBackButton];
    [self createCosmeticTableView];
}

#pragma -mark 创建化妆品TableView
- (void)createCosmeticTableView{
    self.cosmeticTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT )];
    self.cosmeticTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.cosmeticTableView.delegate = self;
    self.cosmeticTableView.dataSource = self;
    [self.view addSubview:self.cosmeticTableView];
}


#pragma -mmark 创建返回按钮
-(void)createBackButton{
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 40)];
    
    
    
    UIButton *backBut = [UIButton buttonWithType:UIButtonTypeCustom];
    //[navBtn setTitle:@"返回" forState:UIControlStateNormal];
    backBut.frame = CGRectMake(0, 10, 30, 18);
    //navBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    backBut.backgroundColor = [UIColor clearColor];
    [backBut setBackgroundImage:[UIImage imageNamed:@"fanhui"] forState:UIControlStateNormal];
    [backBut setBackgroundImage:[UIImage imageNamed:@"fanhui1"] forState:UIControlStateHighlighted];
    [backBut addTarget:self action:@selector(backClick23) forControlEvents:UIControlEventTouchUpInside];
    //[navBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [view addSubview:backBut];
    
    UILabel *title = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2-55, 5, 100, 30)];
    title.textAlignment = NSTextAlignmentCenter;
    title.font = [UIFont fontWithName:@"Helvetica-Bold" size:17];
    title.text = @"化妆品";
    title.textColor = [UIColor whiteColor];
    [view addSubview:title];
    self.navigationItem.titleView = view;
    
//    InformationButton *infonmationBut = [[InformationButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-50, 5, 30, 30)];
//    infonmationBut.informationNum.text = @"20";
//    [infonmationBut setBackgroundImage:[UIImage imageNamed:@"查看库存_03"] forState:UIControlStateNormal];
//    [view addSubview:infonmationBut];
    
}

#pragma -mark 返回按钮事件
- (void)backClick23{
    
    [self.navigationController popViewControllerAnimated:YES];
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0) {
        return 3;
    } else
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        return 90;
    } else
        return 155;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    static NSString *iden = @"sosmetic";
    CosmeticTableViewCell *cell =  [tableView dequeueReusableCellWithIdentifier:iden];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"Shopping_mall_xibs" owner:self options:nil] objectAtIndex:2];
    }
    
    static NSString *iden2 = @"sosmetic2";
    CosMeticList_TableViewCell *cell2 =  [tableView dequeueReusableCellWithIdentifier:iden2];
    if (cell2 == nil) {
        cell2 = [[[NSBundle mainBundle] loadNibNamed:@"Shopping_mall_xibs" owner:self options:nil] objectAtIndex:3];
    }
    if (indexPath.section == 0) {
        return cell;
    }else
    return cell2;

}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
//    CommodityListViewController *listVc = [[CommodityListViewController alloc] init];
//    [self.navigationController pushViewController:listVc animated:YES];
}
@end
